package com.alipay.config;

import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.request.AlipayTradePagePayRequest;
import com.google.gson.Gson;

/**
 * Create By IntelliJ IDEA
 *
 * @author:lww
 * @create-Time: 2017/12/7 10:18
 * @description: ${DESCRIPTION}
 */
public class Alipay {
    private AlipayClient client;
    private AlipayTradePagePayRequest request;

    public Alipay(AlipayClient client, AlipayTradePagePayRequest request) {
        this.client = client;
        this.request = request;
    }
    public Alipay(Boolean shouldReturn){
        client= AlipayFactory.client();
        request=new AlipayTradePagePayRequest();
        if(shouldReturn){
            AlipayFactory.setReturn(request);
        }
    }
    public String excute(AlipayBase args) throws AlipayApiException {
        Gson gson=new Gson();
        String json=gson.toJson(args);
        request.setBizContent(json);
        return client.execute(request).getBody();
    }
}
